using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using PointOfSale.Global ;
using System.Data ;

namespace PointOfSale.Report.Monthly
{
	/// <summary>
	/// Summary description for frmMonthlyReport.
	/// </summary>
	public class frmMonthlyReport : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnReport;
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.LookupComboBox cboYear;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.LookupComboBox cboMonth;
		private System.Windows.Forms.LookupComboBox cboDepartment;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmMonthlyReport()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMonthlyReport));
			this.btnReport = new System.Windows.Forms.Button();
			this.btnClose = new System.Windows.Forms.Button();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label3 = new System.Windows.Forms.Label();
			this.cboDepartment = new System.Windows.Forms.LookupComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.cboMonth = new System.Windows.Forms.LookupComboBox();
			this.cboYear = new System.Windows.Forms.LookupComboBox();
			this.label2 = new System.Windows.Forms.Label();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// btnReport
			// 
			this.btnReport.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnReport.Location = new System.Drawing.Point(172, 120);
			this.btnReport.Name = "btnReport";
			this.btnReport.TabIndex = 18;
			this.btnReport.Text = "Report";
			this.btnReport.Click += new System.EventHandler(this.btnReport_Click);
			// 
			// btnClose
			// 
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnClose.Location = new System.Drawing.Point(252, 120);
			this.btnClose.Name = "btnClose";
			this.btnClose.TabIndex = 19;
			this.btnClose.Text = "Close";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(4, 8);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(104, 96);
			this.pictureBox1.TabIndex = 20;
			this.pictureBox1.TabStop = false;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.cboDepartment);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.cboMonth);
			this.groupBox1.Controls.Add(this.cboYear);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(108, 0);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(232, 112);
			this.groupBox1.TabIndex = 17;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Select Month and Year";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 80);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(64, 16);
			this.label3.TabIndex = 8;
			this.label3.Text = "Department";
			// 
			// cboDepartment
			// 
			this.cboDepartment.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.cboDepartment.Items.AddRange(new object[] {
															   "(All)"});
			this.cboDepartment.Location = new System.Drawing.Point(80, 80);
			this.cboDepartment.Name = "cboDepartment";
			this.cboDepartment.Size = new System.Drawing.Size(121, 21);
			this.cboDepartment.TabIndex = 7;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(40, 16);
			this.label1.TabIndex = 6;
			this.label1.Text = "Month";
			// 
			// cboMonth
			// 
			this.cboMonth.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.cboMonth.ItemHeight = 13;
			this.cboMonth.Items.AddRange(new object[] {
														  "January",
														  "February",
														  "March",
														  "April",
														  "May",
														  "June",
														  "July",
														  "August",
														  "September",
														  "October",
														  "November",
														  "December"});
			this.cboMonth.Location = new System.Drawing.Point(80, 16);
			this.cboMonth.Name = "cboMonth";
			this.cboMonth.Size = new System.Drawing.Size(121, 21);
			this.cboMonth.TabIndex = 5;
			// 
			// cboYear
			// 
			this.cboYear.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.cboYear.ItemHeight = 13;
			this.cboYear.Location = new System.Drawing.Point(80, 48);
			this.cboYear.Name = "cboYear";
			this.cboYear.Size = new System.Drawing.Size(88, 21);
			this.cboYear.TabIndex = 4;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 48);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(64, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "Year";
			// 
			// frmMonthlyReport
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(344, 156);
			this.Controls.Add(this.btnReport);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.groupBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmMonthlyReport";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Monthly Sumary Report";
			this.Load += new System.EventHandler(this.frmMonthlyReport_Load);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmMonthlyReport_Load(object sender, System.EventArgs e)
		{
			//Thiet lap gia tri cho cac LookupComboBox
			cboMonth.Text = "January";
			cboYear.Text = "2005" ;
//			cboMonth.Text = System.Convert.ToString(clsGlobal.g_Month) ;
//			cboYear.Text  = System.Convert.ToString(clsGlobal.g_Year) ;
			
			// Add DepartmentName to cboDepartment
			DataSet ds;
			ds = new DataSet ();					
			ds = clsGlobal.Db.GetDataToDataSet("SELECT deptName FROM tblDepartment",clsGlobal.g_DataConn, "tblDepartment");									
			for (int i = 0; i < ds.Tables["tblDepartment"].Rows.Count; i++)
			{
				string strDepartmentName = ds.Tables ["tblDepartment"].Rows [i]["deptName"].ToString ().Trim () ;								
				cboDepartment.Items.Add (strDepartmentName) ;				
			}
			cboDepartment.Text = "(All)";
		}

		//Thoat
		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Dispose(); 
		}

		//Su kien click nut Report
		private void btnReport_Click(object sender, System.EventArgs e)
		{
			frmMonthlyReportView frm = new frmMonthlyReportView ();

			//thiet lap gia tri cho cac bien cua form frmMonthlyReportView
			string st = cboMonth.Text.Trim (); 
			switch (st)
			{
				case "January":
					frm.intMonth = 1;
					break;
				case "February":
					frm.intMonth = 2;
					break;
				case "March":
					frm.intMonth = 3;
					break;
				case "April":
					frm.intMonth = 4;
					break;
				case "May":
					frm.intMonth = 5;
					break;
				case "June":
					frm.intMonth = 6;
					break;
				case "July":
					frm.intMonth = 7;
					break;
				case "August":
					frm.intMonth = 8;
					break;
				case "September":
					frm.intMonth = 9;
					break;
				case "October":
					frm.intMonth = 10;
					break;
				case "November":
					frm.intMonth = 11;
					break;
				case "December":
					frm.intMonth = 12;
					break;
			}
			frm.strMonth = cboMonth.Text.Trim ();
			frm.intYear = System.Convert.ToInt16(cboYear.Text.Trim ()); 
			frm.strDepartmentName = cboDepartment.Text.Trim ();
			
			frm.ShowDialog();

		}
	}
}
